home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 126-150 / scopedisk126 / cpu2 / cpu.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  2KB  |  113 lines

  1. /*    CPU
  2.  *
  3.  *    Displays CPU type and presence of a math co-processor.
  4.  *    Also Displays video type and whether system clocking is internal
  5.  *        or from a GenLock.
  6.  *
  7.  *    Thad Floryan
  8.  *
  9.  *    V1.0    29-March-1987    original program
  10.  *    V1.1    22-July-1988    separated test for 68881 from 68020 test
  11.  *    V2.0    12-August-1988    added video type and system clocking display
  12.  *
  13.  * Building instructions (Manx):
  14.  *
  15.  *    CLI> cc cpu
  16.  *    CLI> ln cpu -lc
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <exec/exec.h>
  21. #include <exec/types.h>
  22. #include <exec/execbase.h>
  23. #include <exec/libraries.h>
  24. #include <graphics/gfxbase.h>
  25. #include <libraries/dos.h>
  26. #include <libraries/dosextens.h>
  27.  
  28. extern char         *AllocMem();
  29. extern void          CloseLibrary();
  30. extern void          FreeMem();
  31. extern struct Library     *OpenLibrary();
  32. extern struct FileHandle *Output();
  33. extern void          Write();
  34.  
  35. extern struct ExecBase     *SysBase;
  36.  
  37. static char         *buf;
  38. static char         *bufptr;
  39. static struct FileHandle *outfile;
  40.  
  41. static char *Version = "CPU V2.0, Thad Floryan, 12-Aug-1988";
  42.  
  43. #define _WCHR(s) *bufptr++ = s
  44.  
  45. main()
  46. {
  47.     void WSTR();
  48.     register UWORD         Flags;
  49.     register struct GfxBase    *GfxBase;
  50.  
  51.     outfile = Output();        /* initialize output handle */
  52.  
  53.     buf = bufptr = AllocMem(200L, MEMF_CLEAR);
  54.  
  55.     WSTR("The CPU is a 680");
  56.  
  57.     Flags = SysBase->AttnFlags;
  58.  
  59.     if (Flags & AFF_68010)
  60.     {
  61.         if (Flags & AFF_68020)
  62.         _WCHR('2');        /* 68020 */
  63.     else
  64.         _WCHR('1');        /* 68010 */
  65.     }
  66.     else _WCHR('0');        /* 68000 */
  67.     _WCHR('0');
  68.  
  69.     if (Flags & AFF_68881)
  70.     WSTR(" with a 68881");
  71.     _WCHR('\n');
  72.  
  73.     GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 33L);
  74.  
  75.     if (GfxBase)
  76.     {
  77.     WSTR("The video is ");
  78.     if (GfxBase->DisplayFlags & NTSC)
  79.         WSTR("NTSC");
  80.     else
  81.         if (GfxBase->DisplayFlags & PAL)
  82.         WSTR("PAL");
  83.         else
  84.         WSTR("other");
  85.  
  86.     WSTR(" and system clocking is ");
  87.     if (GfxBase->DisplayFlags & GENLOC)
  88.         WSTR("from a GenLock\n");
  89.     else
  90.         WSTR("internal\n");
  91.  
  92.     CloseLibrary(GfxBase);
  93.     }
  94.  
  95.     _WCHR('\0');
  96.  
  97.     Write(outfile, buf, (long)strlen(buf));
  98.     FreeMem(buf, 200L);
  99. }
  100.  
  101. /*
  102.  *    WSTR()  --  appends a string to currently-being-built display buffer
  103.  */
  104.  
  105. void WSTR(sptr)
  106.     char  *sptr;
  107. {
  108.     while (*sptr)
  109.     {
  110.     _WCHR(*sptr++);
  111.     }
  112. }
  113.